home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 255_01 / gioinit.asm < prev    next >
Assembly Source File  |  1988-03-28  |  4KB  |  171 lines

  1.       page     80,132
  2.       page
  3. ;
  4. ;      Kent Cedola
  5. ;      2015 Meadow Lake Court
  6. ;      Norfolk, Virginia  23518
  7. ;
  8.  
  9. dgroup      group  _data
  10.  
  11. _data     segment word public 'data'
  12.       assume ds:dgroup
  13.  
  14. ;------ VEGA HiRes (640x480) Data:
  15.  
  16. Vega_Seg    segment at 0C000h    ;VEGA ROM Segment
  17.         org    028h
  18. mul8_addr    label    word        ;Address of emulation routine
  19.         org    02Ah
  20. version     label    byte        ;Version string
  21.         org    03FFEh
  22. feature     label    byte        ;Feature flags
  23. Vega_Seg    ends
  24.  
  25.  
  26. VerChk  db      'VEGA BIOS Code, ',0    ;VEGA BIOS Version string subset
  27.  
  28. ;
  29. ;    Alt. Mode 10: 640 x 480 16-color graphics (>64k ram):
  30. ;
  31. HiRes_Params    label    byte
  32.     db    80, 36, 14
  33.     dw    0B400h
  34.     db    001h, 00Fh, 000h, 006h
  35.     db    0ABh
  36.     db    064h, 04Fh, 053h, 021h, 053h, 000h
  37.     db    0F0h, 01Fh, 000h, 000h, 000h, 000h
  38.     db    000h, 000h, 000h, 000h, 0E0h, 02Ch
  39.     db    0DFh, 028h, 00Fh, 0E1h, 00Ch, 0E3h
  40.     db    0FFh
  41.     db    000h, 001h, 002h, 003h, 004h, 005h
  42.     db    014h, 007h, 038h, 039h, 03Ah, 03Bh
  43.     db    03Ch, 03Dh, 03Eh, 03Fh, 001h, 000h
  44.     db    00Fh, 000h
  45.     db    000h, 000h, 000h, 000h, 000h, 000h
  46.     db    005h, 00Fh, 0FFh
  47.  
  48.  
  49. Emulate label    dword            ;Far pointer to Emulate routine
  50. EmulOff dw    0
  51. EmulSeg dw    0
  52.  
  53. ;------ End of VEGA Data...
  54.  
  55. _data      ends
  56.  
  57. _text     segment byte public 'code'
  58.  
  59.       assume cs:_text,ds:dgroup
  60.       public _Check_Vega, _Set_Hires
  61.  
  62. ;
  63. ;    Check EGA ROM for VEGA BIOS version string, and 24 Mhz clock feature
  64. ;
  65. ;    Exit:    Carry set:    VEGA Deluxe found
  66. ;        Carry clear:    VEGA Deluxe not found
  67. ;
  68. _Check_Vega    proc    near
  69.  
  70.       push     bp
  71.       mov     bp,sp
  72.       push     si
  73.       push     di
  74.       push     es
  75.       cld                ;Strings go forward
  76.  
  77.     mov    ah,12H            ;Bios alternate select
  78.     mov    bl,10H            ;Return EGA information
  79.     int    10H
  80.     or    bh,bh            ;check for color monitor
  81.     jnz    Chk_Fail        ;if bh=1, mono monitor
  82.  
  83.     mov    ax,Vega_Seg        ;Get VEGA ROM seg
  84.     mov    es,ax            ;copy into ES
  85.     assume    es:Vega_Seg
  86.  
  87.     lea    di,version        ;Point at ROM version string
  88.     lea    si,VerChk        ;Point at version string subset
  89. Chk_Loop:
  90.     lodsb                ;Get source byte
  91.     or    al,al            ;End of string?
  92.     jz    Chk_Equal        ;If at end, set carry (Equal)
  93.     cmp    al,es:[di]        ;Does this byte match?
  94.     jne    Chk_Fail        ;No, exit (Not Equal)
  95.     inc    di            ;Yes, advance dest pointer
  96.     jmp    Chk_Loop        ;Loop over source string
  97. Chk_Fail:
  98.     xor    ax,ax            ;else clear carry
  99.     jmp    short Chk_Exit        ;and exit
  100. Chk_Equal:
  101.         test    es:feature,1            ;Is this a "Deluxe" VEGA?
  102.         jz      Chk_Fail                ;No, can't do sexy hires modes
  103.     mov     ax,1            ;Yes, Set carry flag
  104. Chk_Exit:
  105.  
  106.     pop    es            ;Restore regs
  107.     pop    di
  108.     pop    si
  109.     pop    bp
  110.     ret
  111.  
  112. _Check_Vega    endp
  113.  
  114. ;
  115. ;    Set VEGA HiRes (640x480) mode
  116. ;
  117. _Set_Hires    proc    near
  118.  
  119.       push     bp
  120.       mov     bp,sp
  121.       push     si
  122.       push     di
  123.       push     es
  124.  
  125.     mov    bx,Vega_Seg        ;Setup to get Vega Segment
  126.     mov    es,bx
  127.     assume    es:Vega_Seg
  128.  
  129.     mov    bx,es:Mul8_addr     ;Get offset of emulation routine
  130.     mov    EmulOff,bx        ;Save offset
  131.     mov    EmulSeg,es        ;and segment
  132.  
  133.     push    ds            ;Copy code segment
  134.     pop    es            ;into ES
  135.     lea    di,HiRes_Params     ;Get address of HiRes parameters
  136.     mov    dx,3D4h         ;Get CRT port address
  137.     mov    ax,9            ;Get special mode
  138.     call    Emulate         ;Set EGA registers from param table
  139.  
  140.     mov    ax,040H         ;Get the bios data segment
  141.     mov    es,ax
  142.     mov    word ptr es:[4AH],80    ;Set the number of columns
  143.     mov    byte ptr es:[84H],33    ;Set the number of rows
  144.  
  145.     call    Pal_On            ;Turn the palette on
  146.  
  147.      pop     es            ;Restore registers
  148.      pop     di
  149.      pop     si
  150.      pop     bp
  151.      ret                ;Return
  152.  
  153. _Set_Hires    endp
  154.  
  155. ;
  156. ;    Turn Palette On
  157. ;
  158. Pal_On    proc    near
  159.  
  160.     mov    dx,3DAh         ;Get status port address (Color)...
  161.     in    al,dx            ;Set attribute flip-flop
  162.     mov    dx,3C0h
  163.     mov    al,20h
  164.     out    dx,al            ;Enable palette
  165.     ret
  166.  
  167. Pal_On    endp
  168.  
  169. _text      ends
  170.       end
  171.